﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevenBlog.Core.Entities;

namespace LevenBlog.Core.WebService.Entities
{
    [Serializable]
    public class User
    {
        public int ID { get; set; }

        public int RoleID { get; set; }

        public string Name { get; set; }

        public string Password { get; set; }

        public int PostNum { get; set; }

        public User()
        {
            ID = -1;
            RoleID = 1;
            Name = "游客";
            Password = String.Empty;
            PostNum = 0;
        }

        public virtual void FillWithDbEntity(lb_user user)
        {
            ID = user.id;
            RoleID = user.typeid;
            Name = user.name;
            Password = user.password;
            PostNum = user.postnum;
        }

        public virtual lb_user ToEntity()
        {
            lb_user user = new lb_user();
            user.id = ID;
            user.name = Name;
            user.password = Password;
            user.postnum = PostNum;
            user.typeid = RoleID;
            return user;
        }
    }
}
